import uuid
import os
from datetime import datetime

def get_file_type(filename):
    extension = filename.lower().split('.')[-1]
    text_types = ['txt', 'md', 'doc', 'docx', 'pdf', 'csv', 'xls', 'xlsx', 'xlsm']
    image_types = ['jpg', 'jpeg', 'png', 'gif', 'bmp']
    audio_types = ['mp3', 'wav', 'ogg', 'flac']
    video_types = ['mp4', 'mkv', 'avi', 'mov', 'wmv', 'flv', 'm4v', 'mpeg', 'mpg']
    
    if extension in text_types:
        return 1
    elif extension in image_types:
        return 2
    elif extension in audio_types:
        return 3
    elif extension in video_types:
        return 4
    else:
        return 0  # 未知类型

def generate_uuid():
    return uuid.uuid4().hex

def generate_oss_path(filename):
    today = datetime.now().strftime('%Y%m%d')
    extension = os.path.splitext(filename)[1]
    new_filename = f"{generate_uuid()}{extension}"
    return f"{today}/{new_filename}" 